home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Subject: Re: rand() source
- Message-ID: <DpqLyq.8Kn@rci.ripco.com>
- X-Nntp-Sender: mambuhl@golden.ripco.com
- Sender: usenet@rci.ripco.com (Net News Admin)
- Organization: Ripco Internet BBS Chicago
- Date: Fri, 12 Apr 1996 06:56:50 GMT
-
- luchini@hybrid.ualr.edu (Dr. Chris Luchini)
- in <4kf88n$j5e@news.ualr.edu> asks:
-
- >does anyone have the source for the ran() or rand() functions?
- >I could really use it ASAP!
-
- They could be almost anything in your implementation, but as _examples_
- the standard gives (ISO 7.10.2.2)
-
- static unsigned long int next = 1;
-
- int rand(void) /* RAND_MAX assumed to be 32767 */
- {
- next = next * 1103515245 + 12345;
- return (unsigned int) (next/65536) % 32768;
- }
-
- void srand(unsigned int seed)
- {
- next = seed;
- }
-
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-